package com.ycy.create;

import com.ycy.BaseTest;
import org.flowable.engine.*;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.engine.runtime.ProcessInstanceBuilder;
import org.flowable.task.api.Task;
import org.junit.Test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CreateDemo extends BaseTest {

  @Test
  public void create() {

    Long currentTime = System.currentTimeMillis();
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("employee", "employee" + currentTime);
    variables.put("nrOfHolidays", "nrOfHolidays" + currentTime);
    variables.put("description", "description" + currentTime);

    RuntimeService runtimeService = processEngine.getRuntimeService();

    // 创建流程实例 用户后续等待这个状态即可  发起流程
    ProcessInstance processInstance =
            runtimeService.startProcessInstanceByKey("holidayRequest", variables);

    System.out.println(processInstance.getBusinessKey());
    System.out.println(processInstance.getId());
    System.out.println(processInstance.getProcessInstanceId());

    //创建流程实例
    ProcessInstanceBuilder processInstanceBuilder = runtimeService.createProcessInstanceBuilder();
    processInstanceBuilder.processDefinitionKey("holidayRequest")
            .businessKey(currentTime + "")
            .name("tiao")
            .variables(variables);

    ProcessInstance start = processInstanceBuilder.start();
    System.out.println(start.getBusinessKey());
    System.out.println(start.getId());
    System.out.println(start.getProcessInstanceId());
    //1613564903590 : 52511

  }



}
